package servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import atm.ATM;

/**
 * 
     * @ClassName: TransferServlet
     * @Description: 键入卡号，判断卡号是否存在
     * @author Huang_shengjun
     * @date 2020年5月29日 下午4:12:50
     *
 */
public class TransferServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;
	
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String cardNo = req.getParameter("num");
		System.out.println("==转账的卡号----cardNo-->" + cardNo);
		ATM.getInstance().getSession().getTransaction().setTcardNo(cardNo);
		ATM.getInstance().getSession().getTransaction().TransferIsCard();
		
		String json = ATM.getInstance().getResponse();
		resp.setContentType("text/json");  
		resp.setCharacterEncoding("UTF-8"); 
		resp.getWriter().write(json);
	}

	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req,resp);
	}

}
